#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>

const int buffsize = 1024 * 1024;

int main(int argc, char **argv) {

    if (argc != 2) {
        printf("Usage: ./crefile size\n");
        return 0;
    }

    int nSize = atoi(argv[1]);
    printf("Make %dm data", nSize);

    int fd = open("src.txt", O_WRONLY);
    if (fd == -1) {
        perror("Open error");
        return 0;
    }

    char buff[1024];
    for (int j = 0; j < nSize; j ++) {
        for (int i = 0; i < 1024; i++) {
            buff[i] = (i % 90) + 20;
            if (write(fd, buff, 1024) < 0) {
                perror("write erro");
                break;
            }
        }
    }


    close(fd);

    return 0;
}
